<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Hrm extends MX_Controller {
    
  function __construct() {
    $this->load->library('manimage');
    $this->menu = $this->cek();
  }
	
	public function department(){
    $department = $this->global_models->get("hrm_department");
    $this->template->build("department",
      array(
            'url'         => base_url()."themes/".DEFAULTTHEMES."/",
            'menu'        => 'hrm/department',
            'title'       => lang("department"),
            'data'        => $department
          ));
    $this->template
      ->set_layout('default')
      ->build("department");
	}
	public function add_department($id_hrm_department = 0){
    if($this->input->post()){
      $pst = $this->input->post();
      if($pst['id_detail']){
        $kirim = array(
            "title"           => $pst['title'],
            "code"            => $pst['code'],
            "update_by_users" => $this->session->userdata("id"),
        );
        $id_hrm_department = $this->global_models->update("hrm_department", array("id_hrm_department" => $id_hrm_department), $kirim);
      }
      else{
        $kirim = array(
            "title"           => $pst['title'],
            "code"            => $pst['code'],
            "create_by_users" => $this->session->userdata("id"),
            "create_date"     => date("Y-m-d H:i:s")
        );
        $id_hrm_department = $this->global_models->insert("hrm_department", $kirim);
      }
      if($id_hrm_department){
        redirect("hrm/department/1/Berhasil");
      }
      else{
        redirect("hrm/department/2/Gagal");
      }
    }
    else{
      $department = $this->global_models->get("hrm_department", array("id_hrm_department" => $id_hrm_department));
      $this->template->build("add-department",
        array(
              'url'         => base_url()."themes/".DEFAULTTHEMES."/",
              'menu'        => 'hrm/department',
              'title'       => lang("department"),
              'detail'      => $department
            ));
      $this->template
        ->set_layout('default')
        ->build("add-department");
    }
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */